import {url} from '../utils'
import {FeeFormula} from '@/store/modules/types/FeeFormula'

const state = {
  feeFormula: {} as FeeFormula,
  feeFormulaClone: {} as FeeFormula,
  feeFormulas: [] as FeeFormula[]
}
const getters = {}
const mutations = {
  setActive(state: any, item: FeeFormula) {
    state.feeFormula = item
    state.feeFormulaClone = item
  },
  resetClone(state: any) {
    state.feeFormulaClone = state.feeFormula
  },
}

const actions = {
  list(context: any, opt: any) {
    return axios.post(url('/api/fee-formula/list'), opt)
  },
  createOrUpdate(context: any) {
    return axios.post(url('/api/fee-formula/create-or-update'), {feeFormula: context.state.feeFormulaClone})
  },
  del(context: any, payload: any) {
    return axios.post(url('/api/fee-formula/del'), payload)

  }

}

export default {
  namespaced: true,
  state,
  mutations,
  actions,
  getters
}
